const path = require('path');
const glog = require('glob');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
// const webpack = require('webpack');

module.exports = {
  entry: {
    index:'./src/index.js',
    print:'./src/print.js',
    another:'./src/another.js'
  },
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist'),
    // publicPath:'/'
  }, 
  devtool: 'inline-source-map',
  devServer: {
    contentBase: './dist',
    compress: true,
    port: 9000,
    // clientLogLevel: "none",
    compress: true,
    // hot: true
  },
  module: {
  	rules: [
  		// {
  		// 	test:/\.css$/,
  		// 	use:[
  		// 		'style-loader',
  		// 		'css-loader'
  		// 	]
  		// },
      {
        test:/\.css$/,
        use:ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: 'css-loader'
        })
      },
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          //如果需要，可以在 sass-loader 之前将 resolve-url-loader 链接进来
          use: ['css-loader', 'sass-loader']
        })
      },
      {
        test:/\.(png|jp[e]*g|gif)$/,
        use:[
          {
            loader:'url-loader',
            options: {
              name:'[name].[ext]',
              limit:8000,
              outputPath: 'imgaes/'
            }
          }
        ]
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf|svg)$/,
        use: [
           {
            loader:'file-loader',
            options: {
              name:'[name].[ext]',
              outputPath: 'font/'
            }
          }
        ]
      }
  	]
  },
  plugins: [
    new CleanWebpackPlugin(['dist']),
    new HtmlWebpackPlugin({
      title: '输出管理'
    }),
    new ExtractTextPlugin({
      filename: '[name].css'
    }),
    new UglifyJSPlugin()
    // 单页面程序才用模块热替换
    // new webpack.HotModuleReplacementPlugin(),
  ]
};

function getEntries (){

}